#include <stdio.h>
#if 0
unsigned long long hex2deci(char *str, int n)
{
    unsigned long long result = 0;
    for (int i = 0; (i < n)&&(i < strlen(str)); i ++) {
        if ('0' <= str[i] && str[i] <= '9')
            result = result * 16 + str[i] - '0';
        else if (('A' <= str[i]) && (str[i] <= 'F')) {
            result = result * 16 + str[i] - 'A' + 10;
        }
    }
    return result;
}
#endif
static unsigned long long hex2deci(char * hexstr, int slen)
{
        if (hexstr == NULL)
                    return 0;
            unsigned long long result = 0;
                int len = strlen(hexstr);
                    for (int i = 0; (i < slen)&&(i < len); i ++) {
                                if ('0' <= hexstr[i] && hexstr[i] <= '9')
                                                 result = result * 16 + hexstr[i] - '0';
                                        else if (('A' <= hexstr[i]) && (hexstr[i] <= 'F')) {
                                                        result = result * 16 + hexstr[i] - 'A' + 10;
                                                                }
                                            }
                         return result;
}
int main(int argc, const char *argv[])
{
    char str[128] = {0};
    char *hexstr = "0x55B68A78";
    char *hexstr1 = "0xFFFFFFFF";
    unsigned long TNOS = hex2deci("55B68A78", 8);
    unsigned long NNID = hex2deci("2711", 4);
    unsigned long long CSN = hex2deci("29E0", 4);
    printf("%llu,%llu,%llu\n", NNID, CSN, TNOS);
    TNOS = CSN = NNID = 0;
    sprintf(str, "%05llu%05llu%010llu", NNID, CSN, TNOS);
    printf("%s\n", str);
    //printf("result:%llu\n", hex2deci(hexstr1, strlen(hexstr1)));
    return 0;
}
